﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace GameBanChim_Version1
{
    public class MySprite
    {
        private Texture2D[] _texture2D;

        private int _iCount = 0;//
        private int _nCount = 0;//mac dinh  = 0;

        public Texture2D[] Texture2D
        {
            get { return _texture2D; }
            set 
            {
                _texture2D = value;
                _ntexture2D = _texture2D.Length;
                //_nCount = 0;
            }
        }

        private int _ntexture2D;

        public int Ntexture2D
        {
            get { return _ntexture2D; }
            set { _ntexture2D = value; }
        }

        private int _itexture2D = 0;

        public int Itexture2D
        {
            get { return _itexture2D; }
            set { _itexture2D = value; }
        }

        private float _x;

        public float x
        {
            get { return _x; }
            set { _x = value; }
        }

        private float _y;

        public float y
        {
            get { return _y; }
            set { _y = value; }
        }

        public MySprite(Texture2D[] _textture, float x, float y, int interval)
        {
            Texture2D = _textture;
            _x = x;
            _y = y;
            _nCount = interval;
        }

        public void Update(GameTime gameTime)
        {
            if (_nCount == 0)
            {
                // do something:
                _itexture2D = (_itexture2D + 1) % _ntexture2D;
            }
            else
            {
                _iCount = (_iCount + 1) % _nCount;
                if (_iCount == 0)
                {
                    _itexture2D = (_itexture2D + 1) % _ntexture2D;
                }
                else
                {
                    // do something:
                    int _temp = 1;
                    _temp++;
                    //_itexture2D = (_itexture2D + 1) % _ntexture2D;
                }
            }
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture2D[_itexture2D], new Vector2(_x, _y), Color.White);
        }
    }
}
